#!/bin/bash

set -ux

echo '开放端口'
firewall-cmd --zone=public --add-port=6443/tcp --permanent &&
  firewall-cmd --reload

echo '安装kubectl'
cat >/etc/yum.repos.d/kubernetes.repo <<EOF
[kubernetes]
name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=0
repo_gpgcheck=0
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
EOF

dnf install -y kubectl --disableexcludes=kubernetes &&
  dnf clean all

echo '安装 kind'
curl -Lo ./kind https://cors.isteed.cc/github.com/kubernetes-sigs/kind/releases/download/v0.20.0/kind-linux-amd64
mv ./kind /usr/local/bin/kind &&
  chmod +x /usr/local/bin/kind

echo '验证'
kind version
